﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;

namespace WFA_BANHANG.HeThong
{
    public partial class frmMain : DevExpress.XtraEditors.XtraForm
    {
        public frmMain()
        {
            InitializeComponent();
        }

        //method form load
        private void frmMain_Load(object sender, EventArgs e)
        {
            InitSkins();
            
            barSkin.Caption = "Skin: "+LookAndFeel.SkinName;
        }

        //method tạo nameTab == Icon into FormMain
        private void xtraTabbedMdiManager1_PageAdded(object sender, DevExpress.XtraTabbedMdi.MdiTabPageEventArgs e)
        {
            Icon icon = e.Page.MdiChild.Icon;
            if (icon == null) return;

            MemoryStream imageStream = new MemoryStream();
            icon.Save(imageStream);
            if (imageStream.ToArray().Length == 10134) return;

            Icon iconNew = (Icon.Size.Height != 16) ? new Icon(icon, new Size(16, 16)) : icon;

            e.Page.Image = iconNew.ToBitmap();
        }

        //method assign value skin default for form
        void Default_StyleChanged(object sender, EventArgs e)
        {
            var skin = DevExpress.Skins.CommonSkins.GetSkin(DevExpress.LookAndFeel.UserLookAndFeel.Default);
            barSkin.Caption = "Skin: " + skin.Name;
        }

        //method create Skins
        void InitSkins()
        {
            barManager1.ForceInitialize();
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();
            
            DevExpress.XtraBars.Helpers.SkinHelper.InitSkinPopupMenu(barSkin);
            DevExpress.LookAndFeel.UserLookAndFeel.Default.StyleChanged += new EventHandler(Default_StyleChanged);

        }

        private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

    }//the end class
}//the end namespace